package jianzhi

func reversePrint(head *ListNode) []int {
	res := []int{}

	if head == nil {
		return res
	}

	temp := head
	for temp != nil {
		res = append(res, temp.Val)
		temp = temp.Next
	}

	for i := 0; i < len(res)/2; i++ {
		res[i], res[len(res)-1-i] = res[len(res)-i-1], res[i]
	}

	return res
}
